package pers.qianyu.module.code;

import cn.hutool.core.io.FileUtil;

import java.io.File;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author mizzle rain
 * @date 2021-05-03 20:35
 */
public class DeleteLine {
    public static void main(String[] args) {
        String path = "E:\\Codes\\Gitee\\lamb-lite\\src\\main\\java\\pers\\qianyu";
        List<File> files = FileUtil.loopFiles(path)
                .stream()
                .filter(f -> f.getName().endsWith("Controller.java"))
                .collect(Collectors.toList());
        for (File file : files) {
            List<String> list = FileUtil.readLines(file, "utf-8");
            List<String> collect = list.stream()
                    .filter(l -> !l.contains("@PreAuthorize("))
                    .collect(Collectors.toList());
            FileUtil.writeLines(collect, file.getAbsolutePath(), "utf-8");
        }
    }
}
